package ru.zombator.taskman.client.query.rmi;

import java.net.MalformedURLException;
import java.rmi.Naming;
import java.rmi.NotBoundException;
import java.rmi.RemoteException;

import ru.zombator.taskman.core.query.IPacket;
import ru.zombator.taskman.core.query.IResponderCli;
import ru.zombator.taskman.server.query.rmi.IRmiServer;

/**
 * RMI-клиент.
 * @author nvamelichev
 *
 */
public class RmiClient implements IResponderCli {
	private static final String SERVER_NAME = "dist-taskman";
	
	private IRmiServer remoteSrv;
	
	public RmiClient(String serverIp) throws MalformedURLException, RemoteException, NotBoundException {
		remoteSrv = (IRmiServer) Naming.lookup("rmi://" + serverIp + "/" + SERVER_NAME);
	}
	
	@Override
	public IPacket getResponse(IPacket request) throws RemoteException {
		return remoteSrv.getResponse(request);
	}
}
